﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Configuration
/// </summary>
/// 
public static class Configuration
{
    public static int PersonAttributesCount { get { return CountEnumMembers<PersonAttributes>(); } }
    public static int AccountAttributesCount { get { return CountEnumMembers<AccountAttributes>(); } }
    public static int PaymentAttributesCount { get { return CountEnumMembers<PaymentAttributes>(); } }
    
    // current time + 2 months
    public const int GeneralDueDateTime = 2;

    public enum Tables
    {
        person, account, payment, accountbyperson, paymentsbyperson
    };

    public enum AccountByPerson
    {
        email, id, balance, creation_date, incomes_count,
        outcomes_count
    }

    public enum PaymentsByPerson
    {
        email, id, guid, from_account, creation_date, due_date,
        paid_date, status, type, amount /* KURVA!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */, whom, comment
    }
    
    public enum PersonAttributes
    {
        email, status, first_name, last_name,
        academical_degree, phone, street, city,
        postal_code, account, activation_code
    };

    public enum AccountAttributes
    {
        id, balance, creation_date, incomes_count,
        outcomes_count
    };

    public enum PaymentAttributes
    {
        id, guid, from_account, creation_date, due_date,
        paid_date, status, type, amount, whom, comment
    };

    public enum PersonStatus { active, blocked, waiting_for_activation, deleted }
    public enum PaymentType { check, eshop, money, online }
    public enum PaymentStatus { created, accepted, refused, paid }
    public enum UserRoles { client, admin }

    /// <typeparam name="T">must be enum</typeparam>
    /// <returns>names of enum or null if type is not enum</returns>
    public static string[] EnumtoArray<T>()
    {
        if (typeof(T).IsEnum)
            return Enum.GetNames(typeof(T));
        return null;
    }

    /// <typeparam name="T">must be enum</typeparam>
    /// <returns>enum members count or -1 if type is not enum</returns>
    public static int CountEnumMembers<T>()
    {
        if (typeof(T).IsEnum)
            return Enum.GetValues(typeof(T)).Length;
        return -1;
    }
}
